
package com.xiaoma.myaudience.biz.model;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.ContentValues;
import android.database.Cursor;
import android.os.Parcel;
import android.os.Parcelable;

public class SubscribeLoginInfo extends SubscribeNoLoginInfo {
    public static final String USERID = "userid";

    public String mUserId;

    @Override
    public ContentValues generateContentValues() {
        ContentValues values = super.generateContentValues();
        values.put(USERID, mUserId);
        return values;
    }

    @Override
    public void readFromCursor(Cursor cursor) {
        super.readFromCursor(cursor);
        int index = -1;
        if ((index = cursor.getColumnIndex(USERID)) != -1) {
            mUserId = cursor.getString(index);
            index = -1;
        }
    }

    @Override
    public void readFromJSONObject(JSONObject o) throws JSONException {
        super.readFromJSONObject(o);
        if (o != null) {
            if (o.has(USERID))
                mUserId = o.getString(USERID);
        }
    }

    @Override
    public void readFromParcel(Parcel source) {
        super.readFromParcel(source);
        mUserId = source.readString();
    }

    @Override
    public void writeToParcel(Parcel parcel, int paramInt) {
        super.writeToParcel(parcel, paramInt);
        parcel.writeString(mUserId);
    }

    public static final Parcelable.Creator<SubscribeLoginInfo> CREATOR = new Creator<SubscribeLoginInfo>() {
        public SubscribeLoginInfo createFromParcel(Parcel source) {
            SubscribeLoginInfo info = new SubscribeLoginInfo();
            info.readFromParcel(source);
            return info;
        }

        public SubscribeLoginInfo[] newArray(int size) {
            return new SubscribeLoginInfo[size];
        }
    };
}
